package cn.b.sky.mes.hr.model;

import java.util.ArrayList;
import java.util.Date;
import java.util.List;

import org.apache.commons.lang3.StringUtils;
import org.springframework.format.annotation.DateTimeFormat;
import org.springframework.format.annotation.DateTimeFormat.ISO;

import cn.b.sky.common.model.ImeCommon;

public class Performance extends ImeCommon {
  /**
   * ID
   */
  private Long id;

  /**
   * 排班id，启用排班使用
   */
  private Integer shiftingId;

  /** 
   * 日期
   */
  @DateTimeFormat(pattern = "yyyy-MM-dd")
  private Date theDate;

  /**
   * 人员编号
   */
  private String personnelCode;

  /**
   * 人员姓名，页面展示
   */
  private String personnelName;

  /**
   * 人员类型编号
   */
  private String personnelTypeCode;

  /**
   * 人员类型描述
   */
  private String typeText;

  /**
   * 工作中心编号
   */
  private String workCenterCode;

  /**
   * 工作中心描述
   */
  private String workcenterText;

  /**
   * 实际排班工作中心
   */
  private String shiftingWorkCenterCode;

  /**
   * 实际排班工作中心描述
   */
  private String shiftingWorkcenterText;

  /**
   * 开始时间
   */
  @DateTimeFormat(iso = ISO.DATE_TIME, pattern = "yyyy-MM-dd HH:mm:ss")
  private Date startDatetime;

  /**
   * 结束时间
   */
  @DateTimeFormat(iso = ISO.DATE_TIME, pattern = "yyyy-MM-dd HH:mm:ss")
  private Date endDatetime;

  /**
   * 物料编号
   */
  private String materialCode;

  /**
   * 物料描述， 页面展示
   */
  private String materialText;

  /**
   * 数量
   */
  private Double quantity;

  /**
   * 工时
   */
  private Double workHours;

  /**
   * 描述
   */
  private String memo;

  /**
   * 接收页面的参数
   */
  List<Performance> performances = new ArrayList<Performance>();

  public Long getId() {
    return id;
  }

  public void setId(Long id) {
    this.id = id;
  }

  public Date getTheDate() {
    return theDate;
  }

  public Integer getShiftingId() {
    return shiftingId;
  }

  public void setShiftingId(Integer shiftingId) {
    this.shiftingId = shiftingId;
  }

  public void setTheDate(Date theDate) {
    this.theDate = theDate;
  }

  public String getPersonnelCode() {
    return personnelCode;
  }

  public void setPersonnelCode(String personnelCode) {
    this.personnelCode = personnelCode;
  }

  public String getPersonnelName() {
    return personnelName;
  }

  public void setPersonnelName(String personnelName) {
    this.personnelName = personnelName;
  }

  public String getPersonnelTypeCode() {
    return personnelTypeCode;
  }

  public void setPersonnelTypeCode(String personnelTypeCode) {
    this.personnelTypeCode = personnelTypeCode;
  }

  public String getTypeText() {
    return typeText;
  }

  public void setTypeText(String typeText) {
    this.typeText = typeText;
  }

  public String getWorkCenterCode() {
    return workCenterCode;
  }

  public void setWorkCenterCode(String workCenterCode) {
    this.workCenterCode = workCenterCode;
  }

  public String getWorkcenterText() {
    return workcenterText;
  }

  public void setWorkcenterText(String workcenterText) {
    this.workcenterText = workcenterText;
  }

  public String getShiftingWorkcenterText() {
    return shiftingWorkcenterText;
  }

  public void setShiftingWorkcenterText(String shiftingWorkcenterText) {
    this.shiftingWorkcenterText = shiftingWorkcenterText;
  }

  public String getShiftingWorkCenterCode() {
    return shiftingWorkCenterCode;
  }

  public void setShiftingWorkCenterCode(String shiftingWorkCenterCode) {
    this.shiftingWorkCenterCode = shiftingWorkCenterCode;
  }

  public Date getStartDatetime() {
    return startDatetime;
  }

  public void setStartDatetime(Date startDatetime) {
    this.startDatetime = startDatetime;
  }

  public Date getEndDatetime() {
    return endDatetime;
  }

  public void setEndDatetime(Date endDatetime) {
    this.endDatetime = endDatetime;
  }

  public String getMaterialCode() {
    return materialCode;
  }

  public void setMaterialCode(String materialCode) {
    this.materialCode = materialCode;
  }

  public String getMaterialText() {
    return materialText;
  }

  public void setMaterialText(String materialText) {
    this.materialText = materialText;
  }

  public Double getQuantity() {
    return quantity;
  }

  public void setQuantity(Double quantity) {
    this.quantity = quantity;
  }

  public Double getWorkHours() {
    return workHours;
  }

  public void setWorkHours(Double workHours) {
    this.workHours = workHours;
  }

  public String getMemo() {
    return memo;
  }

  public void setMemo(String memo) {
    this.memo = memo;
  }

  public List<Performance> getPerformances() {
    return performances;
  }

  public void setPerformances(List<Performance> performances) {
    this.performances = performances;
  }

  public boolean isNullObject() {
    if (this.startDatetime == null) {
      return true;
    }
    if (this.endDatetime == null) {
      return true;
    }
    if (StringUtils.isBlank(this.materialCode)) {
      return true;
    }
    if (this.quantity <= 0) {
      return true;
    }
    if (StringUtils.isBlank(this.shiftingWorkCenterCode)) {
      return true;
    }
    if (this.theDate == null) {
      return true;
    }
    if (StringUtils.isBlank(this.personnelCode)) {
      return true;
    }
    /*if(StringUtils.isBlank(this.personnelTypeCode))
     return true;*/
    return false;
  }

}
